package cn.netjava.chapter6;

import java.io.*;


public class CopyFile2 {
	public boolean cp(String src,String dest)throws Exception
	{
		InputStream ins = new FileInputStream(src);
		
		BufferedInputStream bis = new BufferedInputStream(ins);
		
		OutputStream ous = new FileOutputStream(dest);
		
		BufferedOutputStream bos = new BufferedOutputStream(ous);
		
		int i = -1;
		
		while((i=ins.read())!=-1)
		{
			bos.write(i);
		}
		ous.flush();
		
		ins.close();
		
		bis.close();
		
		return true;
		

	}
	
	public static void main(String[] args)throws Exception{
		CopyFile2 cf = new CopyFile2();
		long start = System.currentTimeMillis();
		cf.cp("E:\\ww.rar","bakFile.rar");
		System.out.println(System.currentTimeMillis()-start);
	}
	

}
